package com.itlong.cloud.operate;

import com.itlong.cloud.abstracts.BaseController;
import com.itlong.cloud.noncore.operate.IOperateTimeTaskDeveloperLogClient;
import com.itlong.cloud.thrown.DataAccessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RestController;

/**
 * <desc>
 *      运营开发者日志及操作日志定时任务
 * </desc>
 *
 * @createDate2020/11/9
 **/
@EnableScheduling
@RestController
public class OperateDeveloperLogTimeTask {

    @Autowired
    private IOperateTimeTaskDeveloperLogClient iOperateTimeTaskDeveloperLogClient;
    /**
     * <desc>
     *      定时清除3个月前开发者日志
     * </desc>
     *
     * @param
     * @Author Zhu.yj
     * @createDate  2020/11/9
     */
    //@Scheduled(cron = "0 6 0 * * ?") // 每天凌晨执行
    public void timeTaskClearDeveloperLog(){
        try{
            iOperateTimeTaskDeveloperLogClient.deleteDeveloperLog();
        }catch (Exception e){
            throw new DataAccessException("【定时清除3个月前开发者日志】定时清除3个月前开发者日志失败", e);
        }
    }

    /**
     * <desc>
     *      定时清除登录日志
     * </desc>
     *
     * @param
     * @Author Zhu.yj
     * @createDate  2020/11/9
     */
//    @Scheduled(cron = "0 6 0 * * ?") // 每天凌晨执行
    public void timeTaskClearOperateLog(){
        try {
            iOperateTimeTaskDeveloperLogClient.deleteLoginLog();
        }catch (Exception e){
            throw new DataAccessException("【定时清除3个月前登录日志】定时清除3个月前登录日志失败", e);
        }
    }
}
